wp get acf category in post

95

wp get acf category in post -

<?php 
  $categories= get_the_category();
  if (!empty($categories)) {
    $term_id = $categories[0]->term_id;
    $image = get_field('category-image-field', 'term_'.$term_id);
    // what you do from here depends on what the field is returning
  }
?>

wp retrieve acf by category name -

$category_name = get_field('category-name', $category_id);

Comments

Submit
0 Comments